#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <strings.h>
#include <stdint.h>
#include <ctype.h>
#include <assert.h>

/**********************************************\
*                                              *
*    System error function, doesnt' return     *
*                                              *
\**********************************************/
void sys_error(const char* msg)
{
    perror(msg);
    exit(EXIT_FAILURE);
}

#define MAX_ERROR_STRING_SIZE 512

/**********************************************\
*                                              *
*    Fatal error, doesn't return.              *
*                                              *
\**********************************************/
void fatal(const char* fmt, ...)
{
	if(fmt)
	{
        char errstr[MAX_ERROR_STRING_SIZE];

		va_list marker;
		va_start(marker, fmt);
		vsnprintf(errstr, MAX_ERROR_STRING_SIZE, fmt, marker);
		va_end(marker);
        fprintf(stderr, "%s\n", errstr);
    }
    else
        fprintf(stderr, "error: %s: fmt is NULL!\n", __FILE__);

	exit(EXIT_FAILURE);
}

